home *** CD-ROM | disk | FTP | other *** search
/ X User Tools / X User Tools (O'Reilly and Associates)(1994).ISO / sun4c / archive / tcltk.z / tcltk / man / catn / entry.n < prev    next >
Encoding:
Text File  |  1994-09-20  |  14.5 KB  |  397 lines

  1.  
  2.  
  3.  
  4. entry(n)                   Tk Commands
  5.  
  6.  
  7.  
  8. _________________________________________________________________
  9.  
  10. NAME
  11.      entry - Create and manipulate entry widgets
  12.  
  13. SYNOPSIS
  14.      entry _p_a_t_h_N_a_m_e ?_o_p_t_i_o_n_s?
  15.  
  16. STANDARD OPTIONS
  17.      background      foreground     insertWidth     selectForeground|
  18.      borderWidth     insertBackground               relieftextVariable|
  19.      cursor          insertBorderWidth              scrollCommand  |
  20.      exportSelection insertOffTime  selectBackground               |
  21.      font            insertOnTime   selectBorderWidth              |
  22.  
  23.      See the ``options'' manual entry for details on the standard
  24.      options.
  25.  
  26. WIDGET-SPECIFIC OPTIONS
  27.      Name:           state                                         |
  28.      Class:          State                                         |
  29.      Command-Line Switch:-state                                    |
  30.  
  31.                                                                         ||
  32.           Specifies  one  of two states for the entry:  normal or  |
  33.           disabled.  If the entry is disabled then the value  may  |
  34.           not  be  changed using widget commands and no insertion  |
  35.           cursor will be displayed, even if the input focus is in  |
  36.           the widget.
  37.  
  38.      Name:           width
  39.      Class:          Width
  40.      Command-Line Switch:-width
  41.  
  42.           Specifies an integer value indicating the desired width
  43.           of  the entry window, in average-size characters of the
  44.           widget's font.
  45. _________________________________________________________________
  46.  
  47.  
  48. DESCRIPTION
  49.      The entry command creates a new window (given by  the  _p_a_t_h_-
  50.      _N_a_m_e  argument)  and  makes  it into an entry widget.  Addi-
  51.      tional options, described above, may  be  specified  on  the
  52.      command  line or in the option database to configure aspects
  53.      of the entry such as its  colors,  font,  and  relief.   The
  54.      entry  command  returns  its _p_a_t_h_N_a_m_e argument.  At the time
  55.      this command is invoked, there must not exist a window named
  56.      _p_a_t_h_N_a_m_e, but _p_a_t_h_N_a_m_e's parent must exist.
  57.  
  58.      An entry is a widget that displays a  one-line  text  string
  59.      and  allows  that  string to be edited using widget commands
  60.  
  61.  
  62.  
  63. Tk                                                              1
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. entry(n)                   Tk Commands
  71.  
  72.  
  73.  
  74.      described below, which are typically bound to keystrokes and
  75.      mouse  actions.   When  first  created, an entry's string is
  76.      empty.  A portion of the entry may be selected as  described
  77.      below.   If  an  entry  is  exporting its selection (see the  |
  78.      exportSelection option), then it will observe  the  standard  |
  79.      X11  protocols for handling the selection;  entry selections
  80.      are available as type  STRING.   Entries  also  observe  the
  81.      standard Tk rules for dealing with the input focus.  When an
  82.      entry has the input focus it displays an _i_n_s_e_r_t_i_o_n _c_u_r_s_o_r to
  83.      indicate where new characters will be inserted.
  84.  
  85.      Entries are capable of displaying strings that are too  long
  86.      to  fit  entirely within the widget's window.  In this case,
  87.      only a portion of the string will  be  displayed;   commands
  88.      described  below  may be used to change the view in the win-
  89.      dow.  Entries use the standard scrollCommand  mechanism  for
  90.      interacting  with  scrollbars  (see  the  description of the
  91.      scrollCommand option for details).  They also support  scan-
  92.      ning, as described below.
  93.  
  94.  
  95. WIDGET COMMAND
  96.      The entry command creates a new Tcl command  whose  name  is
  97.      _p_a_t_h_N_a_m_e.  This command may be used to invoke various opera-
  98.      tions on the widget.  It has the following general form:
  99.  
  100.           _p_a_t_h_N_a_m_e _o_p_t_i_o_n ?_a_r_g _a_r_g ...?
  101.  
  102.      _O_p_t_i_o_n and the _a_r_gs determine the exact behavior of the com-
  103.      mand.
  104.  
  105.      Many of the widget commands for entries  take  one  or  more
  106.      indices as arguments.  An index specifies a particular char-
  107.      acter in the entry's string, in any of the following ways:
  108.  
  109.      _n_u_m_b_e_r      Specifies the character as  a  numerical  index,
  110.                  where  0  corresponds  to the first character in
  111.                  the string.
  112.  
  113.      end         Indicates the character just after the last  one
  114.                  in  the  entry's  string.  This is equivalent to
  115.                  specifying a numerical index equal to the length
  116.                  of the entry's string.
  117.  
  118.      insert      Indicates the character adjacent to and  immedi-  |
  119.                  ately following the insertion cursor.
  120.  
  121.      sel.first   Indicates the first character in the  selection.
  122.                  It is an error to use this form if the selection
  123.                  isn't in the entry window.
  124.  
  125.      sel.last    Indicates the last character in  the  selection.
  126.                  It is an error to use this form if the selection
  127.  
  128.  
  129.  
  130. Tk                                                              2
  131.  
  132.  
  133.  
  134.  
  135.  
  136. entry(n)                   Tk Commands
  137.  
  138.  
  139.  
  140.                  isn't in the entry window.
  141.  
  142.      @_n_u_m_b_e_r     In  this  form,  _n_u_m_b_e_r  is  treated  as  an  x-
  143.                  coordinate in the entry's window;  the character
  144.                  spanning that x-coordinate is used.   For  exam-
  145.                  ple, ``@0'' indicates the left-most character in
  146.                  the window.
  147.  
  148.      Abbreviations may be used for any of the forms  above,  e.g.
  149.      ``e''  or  ``sel.f''.   In general, out-of-range indices are
  150.      automatically rounded to the nearest legal value.
  151.  
  152.      The following commands are possible for entry widgets:
  153.  
  154.      _p_a_t_h_N_a_m_e configure ?_o_p_t_i_o_n? ?_v_a_l_u_e _o_p_t_i_o_n _v_a_l_u_e ...?
  155.           Query  or  modify  the  configuration  options  of  the
  156.           widget.   If  no  _o_p_t_i_o_n  is  specified, returns a list
  157.           describing all of the available  options  for  _p_a_t_h_N_a_m_e
  158.           (see  Tk_ConfigureInfo for information on the format of
  159.           this list).  If _o_p_t_i_o_n is specified with no _v_a_l_u_e, then
  160.           the  command  returns  a  list describing the one named
  161.           option (this list will be identical to the  correspond-
  162.           ing  sublist  of  the  value  returned  if no _o_p_t_i_o_n is
  163.           specified).  If one  or  more  _o_p_t_i_o_n-_v_a_l_u_e  pairs  are
  164.           specified,  then  the command modifies the given widget
  165.           option(s) to have the given value(s);  in this case the
  166.           command  returns  an empty string.  _O_p_t_i_o_n may have any
  167.           of the values accepted by the entry command.
  168.  
  169.      _p_a_t_h_N_a_m_e delete _f_i_r_s_t ?_l_a_s_t?
  170.           Delete one or more elements of the  entry.   _F_i_r_s_t  and
  171.           _l_a_s_t are indices of of the first and last characters in
  172.           the range to be deleted.   If _l_a_s_t isn't  specified  it
  173.           defaults  to _f_i_r_s_t, i.e. a single character is deleted.
  174.           This command returns an empty string.
  175.  
  176.      _p_a_t_h_N_a_m_e get
  177.           Returns the entry's string.
  178.  
  179.      _p_a_t_h_N_a_m_e icursor _i_n_d_e_x
  180.           Arrange for the insertion cursor to be  displayed  just  |
  181.           before  the character given by _i_n_d_e_x.  Returns an empty  |
  182.           string.
  183.  
  184.      _p_a_t_h_N_a_m_e index _i_n_d_e_x
  185.           Returns the numerical index corresponding to _i_n_d_e_x.
  186.  
  187.      _p_a_t_h_N_a_m_e insert _i_n_d_e_x _s_t_r_i_n_g
  188.           Insert the characters of _s_t_r_i_n_g just before the charac-
  189.           ter indicated by _i_n_d_e_x.  Returns an empty string.
  190.  
  191.      _p_a_t_h_N_a_m_e scan _o_p_t_i_o_n _a_r_g_s
  192.  
  193.  
  194.  
  195. Tk                                                              3
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. entry(n)                   Tk Commands
  203.  
  204.  
  205.  
  206.           This command is used to implement scanning on  entries.
  207.           It has two forms, depending on _o_p_t_i_o_n:
  208.  
  209.           _p_a_t_h_N_a_m_e scan mark _x
  210.                Records _x and the current view in the  entry  win-
  211.                dow;   used  in conjunction with later scan dragto
  212.                commands.  Typically this  command  is  associated
  213.                with  a  mouse  button  press  in  the widget.  It
  214.                returns an empty string.
  215.  
  216.           _p_a_t_h_N_a_m_e scan dragto _x
  217.                This command computes the difference between its _x
  218.                argument  and the _x argument to the last scan mark
  219.                command for the widget.  It then adjusts the  view
  220.                left  or  right  by  10 times the difference in x-
  221.                coordinates.  This command is typically associated
  222.                with mouse motion events in the widget, to produce
  223.                the effect of dragging the  entry  at  high  speed
  224.                through  the window.  The return value is an empty
  225.                string.
  226.  
  227.      _p_a_t_h_N_a_m_e select _o_p_t_i_o_n _a_r_g
  228.           This command is used to adjust the selection within  an
  229.           entry.  It has several forms, depending on _o_p_t_i_o_n:
  230.  
  231.           _p_a_t_h_N_a_m_e select adjust _i_n_d_e_x
  232.                Locate the end of the  selection  nearest  to  the
  233.                character  given  by _i_n_d_e_x, and adjust that end of
  234.                the selection to be at _i_n_d_e_x  (i.e  including  but
  235.                not  going  beyond  _i_n_d_e_x).   The other end of the
  236.                selection is made  the  anchor  point  for  future
  237.                select   to  commands.   If  the  selection  isn't
  238.                currently in the entry, then a  new  selection  is
  239.                created  to  include  the characters between _i_n_d_e_x
  240.                and  the  most  recent  selection  anchor   point,
  241.                inclusive.  Returns an empty string.
  242.  
  243.           _p_a_t_h_N_a_m_e select clear
  244.                Clear the selection if it  is  currently  in  this
  245.                widget.   If  the  selection  isn't in this widget
  246.                then the command has no effect.  Returns an  empty
  247.                string.
  248.  
  249.           _p_a_t_h_N_a_m_e select from _i_n_d_e_x
  250.                Set the selection anchor point to just before  the
  251.                character  given  by  _i_n_d_e_x.   Doesn't  change the
  252.                selection.  Returns an empty string.
  253.  
  254.           _p_a_t_h_N_a_m_e select to _i_n_d_e_x
  255.                Set the selection to consist of the elements  from
  256.                the anchor point to element _i_n_d_e_x, inclusive.  The
  257.                anchor point is  determined  by  the  most  recent
  258.  
  259.  
  260.  
  261. Tk                                                              4
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. entry(n)                   Tk Commands
  269.  
  270.  
  271.  
  272.                select  from  or  select  adjust  command  in this
  273.                widget.  If the selection  isn't  in  this  widget
  274.                then  a  new  selection  is created using the most
  275.                recent anchor  point  specified  for  the  widget.
  276.                Returns an empty string.
  277.  
  278.      _p_a_t_h_N_a_m_e view _i_n_d_e_x
  279.           Adjust the view in the entry so that element  _i_n_d_e_x  is
  280.           at  the  left  edge  of  the  window.  Returns an empty
  281.           string.
  282.  
  283.  
  284. DEFAULT BINDINGS
  285.      Tk automatically creates class  bindings  for  entries  that  |
  286.      give them the following default behavior:                     |
  287.  
  288.      [1]                                                                ||
  289.           Clicking  mouse  button  1  in  an  entry positions the  |
  290.           insertion cursor just before the  character  underneath  |
  291.           the  mouse  cursor  and  sets  the  input focus to this  |
  292.           widget.                                                  |
  293.  
  294.      [2]                                                                ||
  295.           Dragging  with  mouse  button 1 strokes out a selection  |
  296.           between the insertion cursor and  the  character  under  |
  297.           the mouse.                                               |
  298.  
  299.      [3]                                                                ||
  300.           The  ends  of the selection can be adjusted by dragging  |
  301.           with mouse button 1 while the shift key is down;   this  |
  302.           will  adjust  the end of the selection that was nearest  |
  303.           to the mouse cursor when button 1 was pressed.           |
  304.  
  305.      [4]                                                                ||
  306.           The  view in the entry can be adjusted by dragging with  |
  307.           mouse button 2.                                          |
  308.  
  309.      [5]                                                                ||
  310.           If the input focus is in an entry widget and characters  |
  311.           are typed on the keyboard, the characters are  inserted  |
  312.           just before the insertion cursor.                        |
  313.  
  314.      [6]                                                                ||
  315.           Control-h  and  the Backspace and Delete keys erase the  |
  316.           character just before the insertion cursor.              |
  317.  
  318.      [7]                                                                ||
  319.           Control-w  erases  the  word  just before the insertion  |
  320.           cursor.                                                  |
  321.  
  322.      [8]                                                                ||
  323.           Control-u clears the entry to an empty string.           |
  324.  
  325.  
  326.  
  327. Tk                                                              5
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. entry(n)                   Tk Commands
  335.  
  336.  
  337.  
  338.      [9]                                                                ||
  339.           Control-v inserts the current selection just before the  |
  340.           insertion cursor.                                        |
  341.  
  342.      [10]                                                               ||
  343.           Control-d  deletes  the  selected characters;  an error  |
  344.           occurs if the selection is not in this widget.           |
  345.  
  346.      If the entry is disabled using the state  option,  then  the  |
  347.      entry's view can still be adjusted and text in the entry can  |
  348.      still be selected, but no insertion cursor will be displayed  |
  349.      and no text modifications will take place.                    |
  350.  
  351.      The behavior of entries can be changed by defining new bind-  |
  352.      ings for individual widgets or by redefining the class bind-  |
  353.      ings.
  354.  
  355.  
  356. KEYWORDS
  357.      entry, widget
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393. Tk                                                              6
  394.  
  395.  
  396.  
  397.